<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基层AI辅助诊断系统 - 编辑模板</title>
    <!-- 引入Element Plus的样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <!-- 引入Vue 3 -->
    <script src="https://unpkg.com/vue@3"></script>
    <!-- 引入Element Plus组件库 -->
    <script src="https://unpkg.com/element-plus"></script>
    <!-- 引入中文语言包 -->
    <script src="https://unpkg.com/element-plus/dist/locale/zh-cn.min.js"></script>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
            background: #FFFFFF;
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            margin: 0;
        }

        /* 色彩系统 - 基于HIS系统现代极简风设计规范 */
        :root {
            /* 主色调 */
            --primary: #0F6CBD;
            --primary-light: #D0E7FF;
            --primary-dark: #0A4F8D;
            
            /* 辅助色 */
            --success: #0F8A5F;
            --warning: #F59337;
            --error: #D13438;
            --info: #0078D4;
            
            /* 中性色 - 文字 */
            --text-primary: #1A1A1A;
            --text-secondary: #4D4D4D;
            --text-tertiary: #767676;
            --text-disabled: #A6A6A6;
            
            /* 中性色 - 边框与分割线 */
            --border-strong: #CCCCCC;
            --border-normal: #E0E0E0;
            --border-light: #F0F0F0;
            --divider: #F5F5F5;
            
            /* 中性色 - 背景 */
            --bg-primary: #FFFFFF;
            --bg-secondary: #F9F9F9;
            --bg-card: #FFFFFF;
            --bg-disabled: #F5F5F5;
            
            /* 医疗专业色 */
            --medical-critical: #B91C1C;
            --medical-abnormal: #F59E0B;
            --medical-normal: #10B981;
            --medical-pending: #3B82F6;
            --medical-completed: #9CA3AF;
            
            /* 间距系统 */
            --spacing-2: 2px;
            --spacing-4: 4px;
            --spacing-8: 8px;
            --spacing-12: 12px;
            --spacing-16: 16px;
            --spacing-24: 24px;
            --spacing-32: 32px;
            --spacing-40: 40px;
            --spacing-48: 48px;
            
            /* 字体大小 */
            --font-page-title: 20px;
            --font-card-title: 16px;
            --font-table-title: 14px;
            --font-body: 14px;
            --font-table: 13px;
            --font-small: 12px;
            
            /* 行高 */
            --line-height-title: 1.4;
            --line-height-body: 1.5;
            --line-height-table: 1.2;
            --line-height-form: 1.4;
            
            /* 圆角 */
            --radius-small: 2px;
            --radius-medium: 4px;
            
            /* 动画时间 */
            --transition-fast: 150ms;
            --transition-normal: 200ms;
            --transition-slow: 300ms;
            
            /* 导航统一宽度 */
            --nav-item-width: 140px;
        }

        [v-cloak] {
            display: none;
        }

        /* 布局容器 */
        .container {
            width: 100%;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            background-color: var(--bg-primary);
        }

        /* 顶部导航栏 */
        .header {
            height: 60px;
            background-color: var(--bg-primary);
            border-bottom: 1px solid var(--border-normal);
            display: flex;
            align-items: center;
            padding: 0 var(--spacing-24);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            position: relative;
            z-index: 100;
        }

        .header-spacer {
            width: 200px;
            flex-shrink: 0;
        }

        #app-nav {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            z-index: 10;
            width: calc(100% - 400px); /* 两侧各200px 对称留白 */
            display: flex;
            justify-content: center;
        }
        
        /* Element Plus菜单样式覆盖 */
        .el-menu {
            border: none !important;
            background-color: transparent !important;
        }
        
        .el-menu--horizontal > .el-menu-item,
        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
            height: 60px;
            line-height: 60px;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: var(--font-body);
            padding: 0;
            width: var(--nav-item-width);
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .el-sub-menu__icon-arrow { display: none !important; }

        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title::after {
            content: '';
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-left: 8px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 16px 16px;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu:hover > .el-sub-menu__title::after,
        .el-sub-menu.is-active > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu.is-opened > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 15 12 9 18 15'/></svg>");
        }
        
        .el-menu--horizontal > .el-menu-item.is-active,
        .el-menu--horizontal > .el-sub-menu.is-active .el-sub-menu__title {
            color: var(--primary) !important;
            border-bottom: 2px solid var(--primary);
            font-weight: 500;
        }
        
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover,
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus,
        .el-menu--horizontal > .el-sub-menu:not(.is-disabled):hover .el-sub-menu__title {
            color: var(--primary);
            background-color: transparent;
        }
        
        /* 下拉菜单样式覆盖 */
        .el-menu--popup {
            width: var(--nav-item-width) !important;
            min-width: var(--nav-item-width) !important;
            max-width: var(--nav-item-width) !important;
            border-radius: var(--radius-small);
            padding: 4px 0;
            border: 1px solid var(--border-light);
            border-top: 2px solid var(--primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            text-align: center !important;
        }
        
        .el-menu--popup .el-menu-item {
            height: 36px;
            line-height: 36px;
            padding: 0 !important;
            color: var(--text-secondary);
            white-space: nowrap;
            text-align: center;
            width: var(--nav-item-width) !important;
            box-sizing: border-box;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
            font-size: var(--font-body);
        }
        
        .el-menu--popup .el-menu-item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        /* 用户区域样式 */
        .user-section {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
            margin-left: auto;
            z-index: 10;
            width: 200px;
            justify-content: flex-end;
            flex-shrink: 0;
            cursor: pointer;
            padding: 8px 12px;
            border-radius: var(--radius-small);
            transition: background-color var(--transition-fast);
            color: var(--text-secondary);
        }

        .user-section:hover {
            background-color: var(--bg-secondary);
        }

        .user-name {
            font-weight: 500;
            font-size: var(--font-body);
            color: var(--text-secondary);
        }

        .user-arrow {
            color: var(--text-tertiary);
            transition: color var(--transition-normal);
        }

        .user-section:hover .user-arrow {
            color: var(--primary);
        }

        /* 用户下拉弹窗 */
        .user-dropdown {
            position: absolute;
            top: 60px; /* 紧贴头部底部 */
            right: var(--spacing-24);
            width: 160px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            display: none;
            z-index: 200;
            overflow: hidden;
        }

        .user-dropdown .item {
            padding: 10px 12px;
            color: var(--text-secondary);
            font-size: var(--font-body);
            cursor: pointer;
            white-space: nowrap;
        }

        .user-dropdown .item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        /* 面包屑导航 */
        .breadcrumb {
            padding: var(--spacing-16) var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
            background-color: var(--bg-primary);
        }

        .breadcrumb-item {
            font-size: var(--font-body);
            color: var(--text-tertiary);
            display: inline-flex;
            align-items: center;
        }

        .breadcrumb-item a {
            color: var(--primary);
            text-decoration: none;
        }

        .breadcrumb-item a:hover {
            text-decoration: underline;
        }

        .breadcrumb-separator {
            margin: 0 var(--spacing-8);
            color: var(--text-tertiary);
        }

        .breadcrumb-current {
            color: var(--text-secondary);
            font-weight: 500;
        }
        
        /* 主要内容区域样式 */
        .main-content {
            padding: var(--spacing-24);
            flex: 1;
            background-color: var(--bg-primary);
            width: 100%;
        }
        
        /* 页面标题区域 */
        .page-title-section {
            margin-bottom: var(--spacing-24);
        }
        
        .page-title {
            font-size: var(--font-page-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
        }
        
        /* 表单样式 */
        .form-group {
            margin-bottom: var(--spacing-24);
        }
        
        .form-row {
            display: flex;
            gap: var(--spacing-16);
            margin-bottom: var(--spacing-16);
            flex-wrap: wrap;
        }
        
        .form-item {
            flex: 1;
            min-width: 180px;
            margin-bottom: var(--spacing-16);
        }
        
        .form-label {
            display: block;
            margin-bottom: var(--spacing-8);
            font-weight: 500;
            color: var(--text-secondary);
            font-size: var(--font-body);
        }
        
        .form-control {
            width: 100%;
            padding: var(--spacing-8) var(--spacing-12);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color var(--transition-normal);
            height: 36px; /* 增加高度，解决文字被遮挡问题 */
            line-height: normal; /* 确保行高正常 */
        }
        
        /* 专门针对下拉框的样式调整 */
        select.form-control {
            -webkit-appearance: menulist; /* Safari和Chrome */
            -moz-appearance: menulist; /* Firefox */
            appearance: menulist; /* 标准 */
            padding-right: 24px; /* 为下拉箭头留出空间 */
            background-position: right 8px center;
            background-repeat: no-repeat;
            background-size: 16px;
            vertical-align: middle; /* 确保文字垂直居中 */
            text-overflow: ellipsis; /* 文本溢出时显示省略号 */
            box-sizing: border-box; /* 确保边框和内边距包含在元素宽度内 */
        }
        
        /* 确保下拉选项显示正常 */
        select.form-control option {
            padding: 8px;
            font-size: var(--font-body);
            min-height: 24px; /* 确保选项高度足够 */
            line-height: 1.5;
        }
        
        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }
        
        textarea.form-control {
            min-height: 80px;
            height: auto;
            resize: vertical;
            line-height: var(--line-height-body);
        }
        
        /* 输入组样式 */
        .input-group {
            position: relative;
            display: flex;
            align-items: stretch;
            width: 100%;
        }
        
        .input-group .form-control {
            position: relative;
            flex: 1 1 auto;
            width: 1%;
            min-width: 0;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
        }
        
        .input-group-text {
            display: flex;
            align-items: center;
            padding: var(--spacing-8) var(--spacing-12);
            font-size: var(--font-body);
            font-weight: 400;
            line-height: 1.5;
            color: var(--text-secondary);
            text-align: center;
            white-space: nowrap;
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-normal);
            border-left: none;
            border-radius: 0 var(--radius-small) var(--radius-small) 0;
            height: 36px; /* 与form-control高度一致 */
        }
        
        /* 必填字段标记 */
        .required::after {
            content: '*';
            color: var(--error);
            margin-left: 4px;
        }
        
        /* 卡片样式 */
        .section-card {
            background-color: var(--bg-card);
            border-radius: var(--radius-small);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            border: 1px solid var(--border-light);
            overflow: hidden;
            margin-bottom: var(--spacing-24);
        }
        
        .card-header {
            padding: var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: var(--bg-secondary);
            min-height: 56px;
        }
        
        .card-title {
            font-size: var(--font-card-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
        }
        
        .card-body {
            padding: var(--spacing-16);
        }
        
        /* 按钮样式 */
        .btn {
            padding: var(--spacing-8) var(--spacing-16);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            font-weight: 500;
            cursor: pointer;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-normal);
            gap: var(--spacing-8);
            height: 36px;
            line-height: 1;
        }
        
        /* 折叠面板相关样式 */
        .btn-icon,
        .toggle-icon {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            border-radius: var(--radius-small);
            color: var(--text-tertiary);
            cursor: pointer;
            transition: background-color var(--transition-fast);
        }
        
        .btn-icon:hover,
        .toggle-icon:hover {
            background-color: rgba(0, 0, 0, 0.05);
            color: var(--text-secondary);
        }
        
        .card-header.clickable {
            cursor: pointer;
            user-select: none;
        }
        
        .toggle-icon svg {
            transition: transform var(--transition-normal);
        }
        
        .card-header.expanded .toggle-icon svg {
            transform: rotate(180deg);
        }
        
        .btn .icon {
            flex-shrink: 0;
        }
        
        .btn-primary {
            background-color: var(--primary);
            color: white;
        }
        
        .btn-primary:hover {
            background-color: var(--primary-dark);
        }
        
        .btn-primary:active {
            background-color: var(--primary-dark);
            transform: translateY(1px);
        }
        
        .btn-default {
            background-color: var(--bg-primary);
            color: var(--text-secondary);
            border: 1px solid var(--border-normal);
        }
        
        .btn-default:hover {
            background-color: var(--bg-secondary);
        }
        
        .btn-default:active {
            background-color: var(--bg-secondary);
            transform: translateY(1px);
        }
        
        /* 表格样式 */
        .table-container {
            overflow-x: auto;
            margin-bottom: var(--spacing-16);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
        }
        
        .data-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .data-table th {
            background-color: var(--bg-secondary);
            padding: var(--spacing-8) var(--spacing-16);
            text-align: left;
            font-weight: 600;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-normal);
            height: 32px;
            font-size: var(--font-table-title);
        }
        
        .data-table td {
            padding: var(--spacing-8) var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            color: var(--text-secondary);
            height: 32px;
            vertical-align: middle;
            font-size: var(--font-table);
        }
        
        .data-table tr:hover {
            background-color: var(--bg-secondary);
        }
        
        .empty-table-message {
            text-align: center;
            color: var(--text-tertiary);
            padding: var(--spacing-16);
            font-style: italic;
        }
        
        .btn-sm {
            padding: var(--spacing-4) var(--spacing-8);
            font-size: var(--font-small);
            height: 24px;
        }
        
        /* 底部操作栏 */
        .footer-actions {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            padding: var(--spacing-16) var(--spacing-24);
            margin-top: var(--spacing-24);
            border-top: 1px solid var(--border-light);
            background-color: var(--bg-secondary);
            border-radius: 0 0 var(--radius-small) var(--radius-small);
            position: sticky;
            bottom: 0;
            z-index: 10;
            gap: var(--spacing-16);
        }
        
        /* 响应式样式 */
        @media (max-width: 768px) {
            .header {
                flex-wrap: wrap;
                padding: var(--spacing-12) var(--spacing-16);
                height: auto;
            }
            
            .header-spacer {
                width: 100%;
                justify-content: center;
                margin-bottom: 8px;
            }
            
            .user-section {
                width: 100%;
                justify-content: center;
                order: 3;
                margin-top: 8px;
            }
            
            #app-nav {
                position: relative;
                left: 0;
                transform: none;
                width: 100%;
                order: 3;
                margin-top: var(--spacing-8);
            }
            
            /* Element Plus移动端菜单样式覆盖 */
            .el-menu--collapse {
                width: 100%;
            }
            
            .el-menu--horizontal {
                flex-wrap: wrap;
                width: 100%;
                overflow-x: auto;
                white-space: nowrap;
                -webkit-overflow-scrolling: touch;
                padding-bottom: var(--spacing-4);
                justify-content: center;
            }
            
            .el-menu--horizontal > .el-menu-item,
            .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
                height: 48px;
                line-height: 48px;
            }
            
            .main-content {
                padding: var(--spacing-16);
            }
            
            .form-row {
                flex-direction: column;
            }
            
            .form-item {
                width: 100%;
            }
            
            .footer-actions {
                padding: var(--spacing-16);
            }
        }
    </style>
</head>
<body>
    <div id="app" class="container">
        <!-- 顶部导航栏 - 使用Element Plus组件 -->
        <header class="header">
            <div class="header-spacer"></div>
            <div id="app-nav">
                <el-menu 
                    :default-active="activeIndex" 
                    class="el-menu-demo" 
                    mode="horizontal" 
                    @select="handleSelect"
                    :ellipsis="false"
                    :popper-offset="0"
                    popper-class="custom-dropdown">
                    <el-menu-item index="1">开始问诊</el-menu-item>
                    <el-sub-menu index="2" popper-class="custom-dropdown">
                        <template #title>病历管理</template>
                        <el-menu-item index="2-1">病历查询</el-menu-item>
                        <el-menu-item index="2-2">病历模板</el-menu-item>
                        <el-menu-item index="2-3">个人药品</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="3">患者管理</el-menu-item>
                    <el-sub-menu index="4" popper-class="custom-dropdown">
                        <template #title>数据统计</template>
                        <el-menu-item index="4-1">诊断统计</el-menu-item>
                        <el-menu-item index="4-2">宏观统计</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="5">医学知识</el-menu-item>
                    <el-sub-menu index="6" popper-class="custom-dropdown">
                        <template #title>基础数据</template>
                        <el-menu-item index="6-1">药品管理</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="7" popper-class="custom-dropdown">
                        <template #title>消息通知</template>
                        <el-menu-item index="7-1">通知查看</el-menu-item>
                        <el-menu-item index="7-2">通知发布</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="8" popper-class="custom-dropdown">
                        <template #title>用户管理</template>
                        <el-menu-item index="8-1">用户管理</el-menu-item>
                        <el-menu-item index="8-2">角色管理</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </div>
            <div class="user-section" id="userSection">
                <span class="user-name">张医生</span>
                <svg class="user-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="6 9 12 15 18 9"></polyline>
                </svg>
            </div>
            <div class="user-dropdown" id="userDropdown">
                <div class="item">个人中心</div>
                <div class="item">退出登录</div>
            </div>
        </header>
        
        <!-- 面包屑导航 -->
        <div class="breadcrumb">
            <div class="breadcrumb-item">
                <a href="#">病历模板管理</a>
                <span class="breadcrumb-separator">></span>
                <span class="breadcrumb-current">新增模板</span>
            </div>
        </div>
        
        <!-- 主要内容区域 -->
        <div class="main-content">
            <!-- 页面标题 -->
            <div class="page-title-section">
                <h1 class="page-title">新增模板</h1>
            </div>
            
            <!-- 模板基本信息 -->
            <div class="section-card">
                <div class="card-header">
                    <div class="card-title">模板基本信息</div>
                </div>
                <div class="card-body">
                    <div class="form-group">
                        <div class="form-row">
                            <div class="form-item">
                                <label for="templateName" class="form-label required">模板名称</label>
                                <input type="text" id="templateName" class="form-control" placeholder="请输入模板名称">
                            </div>
                            <div class="form-item">
                                <label for="templateCategory" class="form-label required">所属分类</label>
                                <select id="templateCategory" class="form-control">
                                    <option value="">请选择分类</option>
                                    <option value="1">常见感冒</option>
                                    <option value="2">上呼吸道感染</option>
                                    <option value="3">高血压</option>
                                    <option value="4">糖尿病</option>
                                    <option value="5">消化不良</option>
                                    <option value="6">腰肌劳损</option>
                                    <option value="7">皮肤过敏</option>
                                    <option value="8">儿童发热</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 主诉区域 (固定展开) -->
            <div class="section-card">
                <div class="card-header">
                    <div class="card-title">主诉</div>
                </div>
                <div class="card-body">
                    <div class="form-group">
                        <textarea id="chiefComplaint" class="form-control" placeholder="请输入患者的主要症状和不适"></textarea>
                    </div>
                </div>
            </div>
            
            <!-- 病史区域 -->
            <div class="section-card">
                <div class="card-header clickable" id="historyHeader">
                    <div class="card-title">病史</div>
                    <button class="btn-icon toggle-icon">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <polyline points="6 9 12 15 18 9"></polyline>
                        </svg>
                    </button>
                </div>
                <div class="card-body" id="historyContent">
                    <div class="form-group">
                        <div class="form-row">
                            <div class="form-item">
                                <label for="presentIllness" class="form-label">现病史</label>
                                <textarea id="presentIllness" class="form-control" placeholder="请输入现病史"></textarea>
                            </div>
                            <div class="form-item">
                                <label for="allergyHistory" class="form-label">过敏史</label>
                                <textarea id="allergyHistory" class="form-control" placeholder="请输入过敏史"></textarea>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-item">
                                <label for="pastHistory" class="form-label">既往史</label>
                                <textarea id="pastHistory" class="form-control" placeholder="请输入既往史"></textarea>
                            </div>
                            <div class="form-item">
                                <label for="personalHistory" class="form-label">个人史</label>
                                <textarea id="personalHistory" class="form-control" placeholder="请输入个人史"></textarea>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-item">
                                <label for="familyHistory" class="form-label">家族史</label>
                                <textarea id="familyHistory" class="form-control" placeholder="请输入家族史"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 体格检查区域 -->
            <div class="section-card">
                <div class="card-header clickable" id="physicalExamHeader">
                    <div class="card-title">体格检查</div>
                    <button class="btn-icon toggle-icon">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <polyline points="6 9 12 15 18 9"></polyline>
                        </svg>
                    </button>
                </div>
                <div class="card-body" id="physicalExamContent">
                    <div class="form-group">
                        <label class="form-label">生命体征</label>
                        <div class="form-row">
                            <div class="form-item">
                                <label for="temperature" class="form-label">体温</label>
                                <div class="input-group">
                                    <input type="text" id="temperature" class="form-control" placeholder="请输入">
                                    <span class="input-group-text">℃</span>
                                </div>
                            </div>
                            <div class="form-item">
                                <label for="pulse" class="form-label">脉搏</label>
                                <div class="input-group">
                                    <input type="text" id="pulse" class="form-control" placeholder="请输入">
                                    <span class="input-group-text">次/分</span>
                                </div>
                            </div>
                            <div class="form-item">
                                <label for="respiration" class="form-label">呼吸</label>
                                <div class="input-group">
                                    <input type="text" id="respiration" class="form-control" placeholder="请输入">
                                    <span class="input-group-text">次/分</span>
                                </div>
                            </div>
                            <div class="form-item">
                                <label for="bloodPressure" class="form-label">血压</label>
                                <div class="input-group">
                                    <input type="text" id="bloodPressure" class="form-control" placeholder="请输入">
                                    <span class="input-group-text">mmHg</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="generalCondition" class="form-label">一般状况</label>
                        <textarea id="generalCondition" class="form-control" placeholder="请描述患者一般状况"></textarea>
                    </div>
                    <div class="form-group">
                        <label for="specialExam" class="form-label">专科检查</label>
                        <textarea id="specialExam" class="form-control" placeholder="请描述专科检查结果"></textarea>
                    </div>
                </div>
            </div>
            
            <!-- 诊断区域 -->
            <div class="section-card">
                <div class="card-header clickable" id="diagnosisHeader">
                    <div class="card-title">诊断</div>
                    <button class="btn-icon toggle-icon">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <polyline points="6 9 12 15 18 9"></polyline>
                        </svg>
                    </button>
                </div>
                <div class="card-body" id="diagnosisContent">
                    <div class="form-group">
                        <label for="diagnosis" class="form-label">诊断结果</label>
                        <textarea id="diagnosis" class="form-control" placeholder="请输入诊断结果"></textarea>
                    </div>
                    <div class="form-group">
                        <label for="diagnosisBasis" class="form-label">诊断依据</label>
                        <textarea id="diagnosisBasis" class="form-control" placeholder="请输入诊断依据"></textarea>
                    </div>
                </div>
            </div>
            
            <!-- 处方区域 -->
            <div class="section-card">
                <div class="card-header clickable" id="prescriptionHeader">
                    <div class="card-title">处方</div>
                    <button class="btn-icon toggle-icon">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <polyline points="6 9 12 15 18 9"></polyline>
                        </svg>
                    </button>
                </div>
                <div class="card-body" id="prescriptionContent">
                    <div class="prescription-header" style="display: flex; justify-content: flex-end; margin-bottom: var(--spacing-16);">
                        <button class="btn btn-default" id="addMedicineBtn">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: var(--spacing-8);">
                                <line x1="12" y1="5" x2="12" y2="19"></line>
                                <line x1="5" y1="12" x2="19" y2="12"></line>
                            </svg>
                            添加药品
                        </button>
                    </div>
                    
                    <div class="table-container">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>药名</th>
                                    <th>规格</th>
                                    <th>用法</th>
                                    <th>用量</th>
                                    <th>频次</th>
                                    <th>天数</th>
                                    <th>单价</th>
                                    <th>数量</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="medicineTableBody">
                                <tr>
                                    <td colspan="9" class="empty-table-message">暂无药品，请点击"添加药品"按钮</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <!-- 医嘱区域 -->
            <div class="section-card">
                <div class="card-header clickable" id="adviceHeader">
                    <div class="card-title">医嘱</div>
                    <button class="btn-icon toggle-icon">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <polyline points="6 9 12 15 18 9"></polyline>
                        </svg>
                    </button>
                </div>
                <div class="card-body" id="adviceContent">
                    <div class="form-group">
                        <textarea id="medicalAdvice" class="form-control" placeholder="请输入医嘱内容"></textarea>
                    </div>
                </div>
            </div>
            
            <!-- 底部操作栏 -->
            <div class="footer-actions">
                <button class="btn btn-default" id="cancelBtn">取消</button>
                <button class="btn btn-primary" id="saveBtn">保存</button>
            </div>
        </div>
    </div>
    
    <!-- JavaScript 交互逻辑 -->
    <script>
        // 创建Vue应用
        document.addEventListener('DOMContentLoaded', function() {
            const { createApp, ref } = Vue;
            
            // 创建导航菜单Vue应用
            const navApp = createApp({
                setup() {
                    const activeIndex = ref('2-2'); // 默认选中"病历模板"
                    
                    const handleSelect = (key, keyPath) => {
                        console.log(key, keyPath);
                        // 这里可以添加导航逻辑，如页面跳转等
                    };
                    
                    return {
                        activeIndex,
                        handleSelect
                    };
                }
            });
            
            // 使用Element Plus
            navApp.use(ElementPlus, {
                locale: ElementPlusLocaleZhCn
            });
            
            // 挂载Vue应用
            navApp.mount('#app-nav');
            
            // 初始化所有功能
            initUserDropdown();
            initMedicineTable();
            initButtonActions();
            initCollapsibleSections();
            
            // 用户下拉菜单功能
            function initUserDropdown() {
                const userSection = document.getElementById('userSection');
                const userDropdown = document.getElementById('userDropdown');
                
                if (userSection && userDropdown) {
                    userSection.addEventListener('click', function(e) {
                        e.stopPropagation();
                        const isOpen = userDropdown.style.display === 'block';
                        userDropdown.style.display = isOpen ? 'none' : 'block';
                    });
                    
                    document.addEventListener('click', function() {
                        userDropdown.style.display = 'none';
                    });
                }
            }
            
            // 药品表格功能
            function initMedicineTable() {
                const addMedicineBtn = document.getElementById('addMedicineBtn');
                const medicineTableBody = document.getElementById('medicineTableBody');
                
                if (addMedicineBtn && medicineTableBody) {
                    addMedicineBtn.addEventListener('click', function() {
                        // 检查是否有"暂无药品"的提示行
                        const noMedicineRow = medicineTableBody.querySelector('td.empty-table-message');
                        if (noMedicineRow) {
                            medicineTableBody.innerHTML = '';
                        }
                        
                        const newRow = document.createElement('tr');
                        newRow.innerHTML = `
                            <td contenteditable="true">请输入药名</td>
                            <td contenteditable="true">规格</td>
                            <td contenteditable="true">用法</td>
                            <td contenteditable="true">用量</td>
                            <td contenteditable="true">频次</td>
                            <td contenteditable="true">天数</td>
                            <td contenteditable="true">0.00</td>
                            <td contenteditable="true">0</td>
                            <td>
                                <button class="btn-sm btn-default" onclick="deleteMedicine(this)">删除</button>
                            </td>
                        `;
                        medicineTableBody.appendChild(newRow);
                    });
                }
            }
            
            // 删除药品行功能
            window.deleteMedicine = function(btn) {
                const row = btn.closest('tr');
                row.remove();
                
                // 检查是否还有药品行
                const medicineTableBody = document.getElementById('medicineTableBody');
                if (medicineTableBody && medicineTableBody.querySelectorAll('tr').length === 0) {
                    medicineTableBody.innerHTML = '<tr><td colspan="9" class="empty-table-message">暂无药品，请点击"添加药品"按钮</td></tr>';
                }
            };
            
            // 按钮操作功能
            function initButtonActions() {
                const saveBtn = document.getElementById('saveBtn');
                const cancelBtn = document.getElementById('cancelBtn');
                
                if (saveBtn) {
                    saveBtn.addEventListener('click', function() {
                        // 验证必填字段
                        if (validateRequiredFields()) {
                            alert('模板保存成功！');
                            // 这里可以添加保存后的跳转逻辑
                        } else {
                            alert('请填写所有必填字段（标记有*）');
                        }
                    });
                }
                
                if (cancelBtn) {
                    cancelBtn.addEventListener('click', function() {
                        if (confirm('确定要取消编辑吗？所有更改将不会保存。')) {
                            // 这里可以添加取消后的跳转逻辑
                            window.history.back();
                        }
                    });
                }
            }
            
            // 初始化折叠面板功能
            function initCollapsibleSections() {
                // 定义所有可折叠的区域（不包括主诉区域，它始终保持展开）
                const sections = [
                    { header: 'historyHeader', content: 'historyContent' },
                    { header: 'physicalExamHeader', content: 'physicalExamContent' },
                    { header: 'diagnosisHeader', content: 'diagnosisContent' },
                    { header: 'prescriptionHeader', content: 'prescriptionContent' },
                    { header: 'adviceHeader', content: 'adviceContent' }
                ];
                
                // 为每个区域添加点击事件
                sections.forEach(section => {
                    const headerEl = document.getElementById(section.header);
                    const contentEl = document.getElementById(section.content);
                    
                    if (headerEl && contentEl) {
                        // 默认所有区域折叠
                        headerEl.classList.remove('expanded');
                        
                        // 添加点击事件
                        headerEl.addEventListener('click', function() {
                            toggleSection(this, contentEl);
                        });
                        
                        // 初始状态设置为折叠
                        contentEl.style.display = 'none';
                    }
                });
            }
            
            // 切换区域的展开/折叠状态
            function toggleSection(header, contentEl) {
                const isExpanded = header.classList.contains('expanded');
                
                if (isExpanded) {
                    header.classList.remove('expanded');
                    contentEl.style.display = 'none';
                } else {
                    header.classList.add('expanded');
                    contentEl.style.display = 'block';
                }
            }
            
            // 验证必填字段
            function validateRequiredFields() {
                // 模板基本信息
                const templateName = document.getElementById('templateName').value;
                const templateCategory = document.getElementById('templateCategory').value;
                
                return templateName && templateCategory;
            }
        });
    </script>
</body>
</html>
